<include file="public@header" />
<style>
    .label {
        cursor: pointer;
    }

    .tips {
        display: none;
        position: fixed;
        top: 40%;
        left: 40%;
        min-width: 200px;
        max-width: 700px;
        transform: translate(-50%, -50%);
        z-index: 99999;
        text-align: center;
        padding: 15px;
        border-radius: 5px;
        color: black;
        background-color: #f2dede;
        border-color: #d6e9c6;
    }

    .edits {
        cursor: pointer;
        color: coral;
    }
</style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInUp js-check-wrap">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>激活码列表</h5>
                        <div class="ibox-tools">
                            <a href="#" class="btn btn-primary btn-xs active">激活码列表</a>
                            <a href="{:url('Cdkey/add')}" class="btn btn-primary btn-xs">添加激活码</a>
                        </div>
                    </div>


                    <div class="ibox-content">
                        <div class="tips"></div><!-- 提示框 -->
                        <form class="js-ajax-form" action="{:url('Shop/listorderss')}" method="post">
                            <div class="table-actions">
                            </div>
                            <table class="table table-hover" id="menus-table">
                                <thead>
                                    <tr>
                                        <th width="40">ID</th>
                                        <th>备注</th>
                                        <th>激活码</th>
                                        <th>创建时间</th>
                                        <th>是否售出</th>
                                        <th>售出价格</th>
                                        <th>购买时间</th>
                                        <th>购买用户ID</th>
                                        <th>购买用户名</th>
                                        <th>状态</th>
                                        <th width="150">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <eq name="datas" value="">
                                        <tr>
                                            <td colspan="5" style="text-align: center">暂无数据</td>
                                        </tr>
                                        <else />
                                        <foreach name="datas" item="vo">
                                            <tr>
                                                <td>{$vo.id}</td>
                                                <td>{$vo.memo}</td>
                                                <td>{$vo.keys}</td>
                                                <td>{$vo.ctime|date="Y-m-d H:i",###} </td>
                                                <td>
                                                    <eq name="vo.selled" value="1">
                                                        <span style="color:red">已售出</span>
                                                    </eq>
                                                    <eq name="vo.selled" value="0">
                                                        未售出
                                                    </eq>
                                                </td>
                                                <td>
                                                    <eq name="vo.selled" value="1">
                                                        {$vo.price} {$vo.coin_symbol}
                                                    </eq>
                                                </td>
                                                <td>
                                                    <eq name="vo.selled" value="1">
                                                        {$vo.sell_time|date="Y-m-d H:i",###}
                                                    </eq>
                                                </td>
                                                <td>
                                                    <eq name="vo.selled" value="1">
                                                        {$vo.uid}
                                                    </eq>
                                                </td>
                                                <td>
                                                    <eq name="vo.selled" value="1">
                                                        {$vo.username}
                                                    </eq>
                                                </td>
                                                <td>
                                                    <eq name="vo.status" value="1">
                                                        <span class="label label-info"
                                                            onclick="checktag('{$vo.id}','status','0')">正常</span>&nbsp;&nbsp;&nbsp;
                                                        <else />
                                                        <span class="label label-default"
                                                            onclick="checktag('{$vo.id}','status','1')">已停用</span>&nbsp;&nbsp;&nbsp;
                                                    </eq>
                                                </td>
                                                <td>
                                                    <a href="{:url('Cdkey/edits',['id'=> $vo.id  ]  )}">修改</a> |
                                                    <a href="{:url('Cdkey/del',['id'=> $vo.id  ]  )}"
                                                        class="js-ajax-delete">删除</a>|
                                                    <a href="{:url('Cdkey/log',['keys'=> $vo.keys  ]  )}">使用记录</a </td>
                                            </tr>
                                        </foreach>
                                    </eq>
                                </tbody>
                            </table>
                    </div>
                    <div class="pagination"></div>
                    </form>

                </div>
            </div>
        </div>
    </div>
    <script src="__STATIC__/js/admin.js"></script>
    <script>
        function checktag(id, tag, type) {
            $.ajax({
                url: "{:url('Cdkey/uptag')}",
                type: "post",
                data: { id: id, tag: tag, type: type },
                success: function (data) {

                    $('.tips').text(data).fadeIn().delay(1500).fadeOut();
                    document.location.reload();


                }
            })
        }
    </script>
</body>

</html>